package com.smalljj.dao.impl;

import java.util.List;
import java.util.Map;

import com.smalljj.bean.Friend;
import com.smalljj.dao.FriendDao;

public class FriendDaoImpl extends MiddleAbstractDao<Friend> implements FriendDao {
	
	@Override
	protected Class<Friend> getEntityClass() {
		return Friend.class;
	}

	@Override
	public List<Map<String,Object>> getFriendList(String userId) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" select a.id,a.buser,a.friendname,a.canview,b.lastactivedate,b.lastactivedate,b.nowlon,b.nowlat  ");
		sql.append(" from  friend  a ");
		sql.append(" inner join user b on a.buser = b.id  ");
		sql.append(" where a.auser =  " + userId);
		return super.findBySqlToMapList(sql.toString());
	}

	@Override
	public Friend getFriend(String auser, String buser) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append(" select * from friend where auser = "+auser+ " and buser =" +buser);
		return super.findBySqlToBean(sql.toString());
	}

}
